cd $rspath
use rs_baseline_id_conc19962006, clear
	g hs6=hs6_2002
	merge m:1 hs6 using rs_20112017  // 2011-2017
	drop if _m==2 
	drop _m 
	sort hs6_2002
	destring hs6_2002, replace
	merge m:1 hs6_2002 using $sectorpath/bec_hs2002
	drop if _m==2 
	drop _m 
	g durable =  becproductcode==41 | becproductcode==51 | becproductcode==61 | becproductcode==522 | becproductcode==521 | becproductcode==42 

collapse (mean) rs_hs6_b rs_hs6_20112017b   (max) durable, by(id_conc) 
	egen centile=xtile(rs_hs6_b) , nq(100) // pctiles
	*drop rs_hs6_b 
save $tempath/temp, replace 

cd $firmpath
use new WUI_  rs_hs6_b uncertainty gr_gdp new pm trim ct cty pmt year id_conc iso2 export die using  base4reg_u19962010, clear
merge m:1 id_conc using $tempath/temp 



foreach rs in rs_hs6_b rs_hs6_20112017b   centile {
	g `rs'_uncert=uncertainty*`rs'
	g `rs'_gdp=gr_gdp*`rs' 
	}

local rs rs_hs6_b
reg new uncertainty `rs'_uncert gr_gdp `rs'_gdp  if year > 1999,     vce(robust)
outreg2 using $outputpath/table_online_9.xls, replace ctitle(log(exports)) dec(3) 
reg new uncertainty `rs'_uncert gr_gdp `rs'_gdp  if year > 1999,    vce(robust)
outreg2 using $outputpath/table_online_10.xls, replace ctitle(log(exports)) dec(3) 

foreach rs in rs_hs6_b rs_hs6_20112017b centile {
	
ppmlhdfe new uncertainty `rs'_uncert gr_gdp `rs'_gdp  if year > 1999, a(pmt cty)  tol(1.000e-06) vce(robust)
outreg2 using $outputpath/table_online_9.xls, append ctitle(log(exports)) dec(3)
ppmlhdfe new `rs'_uncert `rs'_gdp if year > 1999, a(pm ct)  tol(1.000e-06) vce(robust)
outreg2 using $outputpath/table_online_9.xls, append ctitle(log(exports)) dec(3)
ppmlhdfe die uncertainty  `rs'_uncert  gr_gdp `rs'_gdp if year < 2007, a(pmt cty)  tol(1.000e-06) vce(robust)
outreg2 using $outputpath/table_online_10.xls, append ctitle(log(exports)) dec(3)
ppmlhdfe die uncertainty  `rs'_uncert `rs'_gdp  if year < 2007, a(pm ct)  tol(1.000e-06) vce(robust)
outreg2 using $outputpath/table_online_10.xls, append ctitle(log(exports)) dec(3)
}


foreach rs in rs_hs6_b {
	
ppmlhdfe new uncertainty `rs'_uncert gr_gdp `rs'_gdp  if year > 1999 & durable==0, a(pmt cty)  tol(1.000e-06) vce(robust)
outreg2 using $outputpath/table_online_9.xls, append ctitle(log(exports)) dec(3)
ppmlhdfe new `rs'_uncert `rs'_gdp if year > 1999 & durable==0, a(pm ct)  tol(1.000e-06) vce(robust)
outreg2 using $outputpath/table_online_9.xls, append ctitle(log(exports)) dec(3)
ppmlhdfe die uncertainty  `rs'_uncert  gr_gdp `rs'_gdp if year < 2007 & durable==0, a(pmt cty)  tol(1.000e-06) vce(robust)
outreg2 using $outputpath/table_online_10.xls, append ctitle(log(exports)) dec(3)
ppmlhdfe die uncertainty  `rs'_uncert `rs'_gdp  if year < 2007 & durable==0, a(pm ct)  tol(1.000e-06) vce(robust)
outreg2 using $outputpath/table_online_10.xls, append ctitle(log(exports)) dec(3)

}



use  $firmpath/base4reg_nomne19962010, clear 
drop _m 
merge m:1 id_conc using $tempath/temp 

drop _m 
merge m:1 iso2 trim year using $countrypath/uncertainty
drop _m

foreach rs in rs_hs6_b  {
	g `rs'_uncert=uncertainty*`rs'
	g `rs'_gdp=gr_gdp*`rs' 
	}

local rs rs_hs6_b
ppmlhdfe new uncertainty `rs'_uncert gr_gdp `rs'_gdp  if year > 1999  , a(pmt cty)  tol(1.000e-06) vce(robust)
outreg2 using $outputpath/table_online_9.xls, append ctitle(log(exports)) dec(3)
ppmlhdfe new `rs'_uncert `rs'_gdp if year > 1999  , a(pm ct)  tol(1.000e-06) vce(robust)
outreg2 using $outputpath/table_online_9.xls, append ctitle(log(exports)) dec(3)

local rs rs_hs6_b
ppmlhdfe die uncertainty  `rs'_uncert  gr_gdp `rs'_gdp if year < 2007 , a(pmt cty)  tol(1.000e-06) vce(robust)
outreg2 using $outputpath/table_online_10.xls, append ctitle(log(exports)) dec(3)
ppmlhdfe die uncertainty  `rs'_uncert `rs'_gdp  if year < 2007  , a(pm ct)  tol(1.000e-06) vce(robust)
outreg2 using $outputpath/table_online_10.xls, append ctitle(log(exports)) dec(3)
